home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Opus5.5 / ARexx.lha / ARexx / VirusZ.dopus5 < prev    next >
Text File  |  1996-06-13  |  5KB  |  139 lines

  1. /* VirusZ for Directory Opus 5.5 and VirusZ.
  2.    by Leo 'Nudel' Davidson for Gods'Gift Utilities
  3.    email: leo.davidson@keble.oxford.ac.uk  www: http://users.ox.ac.uk/~kebl0364
  4.  
  5. $VER: VirusZ.dopus 1.1 (13.6.96)
  6.  
  7.    VirusZ II [v1.31] (C)1991-96 by Georg Hörmann.
  8.    Checks selected files and directories in the source lister.
  9.    (I can add filename-on-commandline support if anyone wants it).
  10.  
  11.    If VirusZ's ARexx port is not found, the program will be run for
  12.    you (you should edit the path below) and quit afterwards.
  13.  
  14.    Thanks to John Veldthuis <johnv@tower.actrix.gen.nz> for giving
  15.    me a virus-infected file (!) to test my Virus_Checker7.dopus
  16.    script which this one was based on.
  17.  
  18. Call as:
  19. ------------------------------------------------------------------------------
  20. ARexx:    DOpus5:ARexx/VirusZ.dopus5 {Qp} {Ql}
  21. ------------------------------------------------------------------------------
  22. Turn off all switches.
  23.  
  24. --- Path to Virus_Checker command ------------------------------------------*/
  25. VirusZ = "DH0:Tools/Virus/VirusZ"
  26. /*--------------------------------------------------------------------------*/
  27.  
  28. options results
  29. options failat 99
  30. signal on syntax;signal on ioerr        /* Error trapping */
  31. parse arg DOpusPort source_handle.0 FilePath
  32.  
  33. If DOpusPort="" THEN Do
  34.     Say "Not correctly called from Directory Opus 5!"
  35.     Say "Load this ARexx script into an editor for more info."
  36.     EXIT
  37.     END
  38. If ~Show("P",DOpusPort) Then Do
  39.     Say DOpusPort "is not a valid port."
  40.     EXIT
  41.     End
  42. Address value DOpusPort
  43.  
  44. dopus version
  45. If ( result='RESULT' | translate(result,'.',' ') < 5.1218 ) then do
  46.     dopus request '"This script requires DOpus v5.5 or greater." OK'
  47.     EXIT
  48.     end
  49.  
  50. Quit_After = "NO"
  51. If ~Show("P",'VIRUSZ_II.REXX') Then Do
  52.     Address Command VirusZ
  53.     Address Command "WaitForPort" 'VIRUSZ_II.REXX'
  54.     Quit_After = "YES"
  55.     If ~Show("P",'VIRUSZ_II.REXX') then do
  56.         lister request source_handle.0 '"Error loading VirusZ!'|| '0a'x ||'Check its command-path in the ARexx script." OK'
  57.         EXIT
  58.         END
  59.     END
  60.  
  61. /* If file/dir-path was specified on command line, check it, else
  62.    go through all the selected ones. */
  63.  
  64. BadList = ""
  65. BadNumber = 0
  66.  
  67. lister set source_handle.0 busy 1
  68.  
  69. lister query source_handle.0 numselentries    /* Get info about selected */
  70. Lister_NumSelEnt = RESULT            /* entries & path to them */
  71. lister query source_handle.0 path
  72. Lister_Path = Strip(RESULT,"B",'"')
  73.  
  74. lister set source_handle.0 newprogress abort bar name title
  75. lister set source_handle.0 newprogress title "Checking for viruses..."
  76. lister set source_handle.0 newprogress info "Checking for viruses..."
  77. lister set source_handle.0 newprogress bar Lister_NumSelEnt 0
  78.  
  79. Do i=1 to Lister_NumSelEnt
  80.     lister query source_handle.0 abort
  81.     If RESULT=1 Then Call END_PART_2
  82.  
  83.     lister query source_handle.0 firstsel
  84.     Temp_Name = Strip(RESULT,"B",'"')
  85.     lister select source_handle.0 '"'Temp_Name'"' 0
  86.     Temp_Path = Lister_Path || Temp_Name
  87.     lister set source_handle.0 newprogress name Temp_Name
  88.     lister set source_handle.0 newprogress bar Lister_NumSelEnt i
  89.     lister query source_handle.0 entry '"'Temp_Name'"'
  90.     Temp_Type = Word(RESULT,(Words(RESULT)) - 4)
  91.     Select
  92.         When Temp_Type < 0 Then
  93.             Address 'VIRUSZ_II.REXX' "CHECKDIR" '"'Temp_Path'"' "DECREXEC DECRDATA"
  94.         When Temp_Type > 0 Then
  95.             Address 'VIRUSZ_II.REXX' "CHECKFILE" '"'Temp_Path'"' "DECREXEC DECRDATA"
  96.         When Temp_Type = 0 Then do
  97.             lister request source_handle.0 '"Error: listery query entry format changed." OK'
  98.             Call END_PART_2
  99.             END
  100.         End
  101.  
  102.     If RC = 10 Then
  103.         lister request source_handle.0 "'Error: VirusZ could not check"||"0a"x||Temp_Path"' OK"
  104.     If RC = 5 Then do
  105.         command flash
  106.         command beep
  107.         BadNumber = BadNumber + 1
  108.         BadList = BadList||'0a'x||Temp_Path
  109.         END
  110.     End
  111.  
  112. If BadNumber > 0 Then Do
  113.     If BadNumber = 1 Then
  114.         BadNote = "The following is infected:›0m"
  115.     Else
  116.         BadNote = "The following are infected:›0m"
  117.     BadList = "›0;41;30m *VIRUS WARNING* ›0m"||'0a'x||"›1m"BadNote||'0a'x||BadList
  118.     dopus front
  119.     dopus screen
  120.     doscr = RESULT ; dosname=Word(doscr,"1") ; dosbar=Word(doscr,"5")+1 ; doswidth=Word(doscr,"2") ; dosheight=Word(doscr,"3")-dosbar
  121.     Open(Output_Shell,"CON:0/"|| dosbar ||"/"|| doswidth ||"/"|| dosheight ||"/Virus Warning/CLOSE/WAIT/SCREEN"||dosname,"W")
  122.     WriteLN(Output_Shell,BadList)
  123.     command wait alarm
  124.     Close(Output_Shell)
  125.     END
  126.  
  127. /*-- Restore the Lister for normal use --------------------------------------*/
  128. syntax:;ioerr:
  129. END_PART_2:
  130.  
  131. lister set source_handle.0 newprogress off
  132.  
  133. lister refresh source_handle.0
  134. lister set source_handle.0 busy 0
  135.  
  136. END_PART:
  137. If Quit_After = "YES" Then Address 'VIRUSZ_II.REXX' "QUIT"
  138. EXIT
  139.